In HTML, elements are broadly divided into two categories: block-level and inline. Block elements always start on a new line and take up the full width, while inline elements only take as much width as the content requires.
[Block Elements] [Inline Elements] [Comparison]
Explanation: <div> is a generic block-level container used to group elements.
This is a paragraph element.
Explanation: <p> defines a paragraph and always starts on a new line.
Explanation: <h1>-<h6> are block elements for headings, taking full width.
Explanation: <ul> defines an unordered list (bulleted).
Explanation: <ol> defines an ordered list (numbered).
"Coding is the new literacy."
Explanation: <blockquote> is used for long quotations as a block element.
Explanation: <hr> defines a horizontal rule, a thematic break in content.
Row1 Col1 | Row1 Col2 |
Row2 Col1 | Row2 Col2 |
Explanation: <table> is a block-level element for tabular data.
This is a span inside text.
Explanation: <span> is an inline container with no new line.
Visit Example Website.
Explanation: <a> defines a hyperlink inline.
This is bold text and this is strong text.
Explanation: <b> and <strong> highlight text inline (strong is semantic).
This is italic text and this is emphasized text.
Explanation: <i> and <em> display text in italics, inline.
This is underlined text.
Explanation: <u> underlines text inline.
E = mc2
Explanation: <sup> defines superscript inline.
H2O
Explanation: <sub> defines subscript inline.
This is highlighted text.
Explanation: <mark> highlights text inline.
We use HTML every day.
Explanation: <abbr> defines abbreviations inline.
Example code: console.log("Hello World");
Explanation: <code> is inline for code snippets.
Block Elements | Inline Elements |
---|---|
<div> | <span> |
<p> | <a> |
<h1> | <b> |
<ul> | <i> |
<blockquote> | <abbr> |
<table> | <code> |
<hr> | <sup> |
<section> | <mark> |